package com.huangyi.mstemplateservice.controller;


import com.fasterxml.jackson.core.type.TypeReference;
import com.github.benmanes.caffeine.cache.Cache;
import com.huangyi.commoncache.utils.CacheUtil;
import com.huangyi.commonredis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/test/cache")
public class TestCacheController {
    @Autowired
    private RedisService redisService;
    @Autowired
    private Cache<String, Object> caffeineCache;
    @GetMapping("/get")
    public String get() {
        String key = "key";
        String l2Cache = CacheUtil.getL2Cache(redisService, key, new TypeReference<String>() {
        }, caffeineCache);
        System.out.println(l2Cache);
        return "success";
    }


}
